
const initialState = {
    users: [],
};

function userReducer(state = initialState, action) {
    switch (action.type) {
        case "ADD_USER":
            return {
                ...state,
                users: [...state.users, action.payload],
            };
        case "DELETE_USER":
            const newUsers = state.users.filter((user) => user.id !== action.payload);
            return {
                ...state,
                users: newUsers,
            };
        default:
            return state;
    }
}

export default userReducer;